#include "pagepecu.h"
#include "ui_pagepecu.h"

PagePECU::PagePECU(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PagePECU)
{
    ui->setupUi(this);
    setAutoFillBackground(true);  //设置自动填充
    QPalette palette = BKGCLR;
    setPalette(palette);

    m_lPECUBtnList.append(ui->PECU1_1);
    m_lPECUBtnList.append(ui->PECU2_1);
    m_lPECUBtnList.append(ui->PECU3_1);
    m_lPECUBtnList.append(ui->PECU4_1);
    m_lPECUBtnList.append(ui->PECU1_2);
    m_lPECUBtnList.append(ui->PECU2_2);
    m_lPECUBtnList.append(ui->PECU3_2);
    m_lPECUBtnList.append(ui->PECU4_2);
    m_lPECUBtnList.append(ui->PECU1_3);
    m_lPECUBtnList.append(ui->PECU2_3);
    m_lPECUBtnList.append(ui->PECU3_3);
    m_lPECUBtnList.append(ui->PECU4_3);
    m_lPECUBtnList.append(ui->PECU1_4);
    m_lPECUBtnList.append(ui->PECU2_4);
    m_lPECUBtnList.append(ui->PECU3_4);
    m_lPECUBtnList.append(ui->PECU4_4);
    m_lPECUBtnList.append(ui->PECU1_5);
    m_lPECUBtnList.append(ui->PECU2_5);
    m_lPECUBtnList.append(ui->PECU3_5);
    m_lPECUBtnList.append(ui->PECU4_5);
    m_lPECUBtnList.append(ui->PECU1_6);
    m_lPECUBtnList.append(ui->PECU2_6);
    m_lPECUBtnList.append(ui->PECU3_6);
    m_lPECUBtnList.append(ui->PECU4_6);



    for (int i=0;i<m_lPECUBtnList.length() ;i++ ) {
        m_lPECUBtnList[i]->hide();
    }
}

PagePECU::~PagePECU()
{
    delete ui;
}

void PagePECU::setPECUStat(uint8_t index, uint8_t stat)
{
    if(index >= m_lPECUBtnList.length())
        return;
    m_lPECUBtnList[index]->show();
    switch (stat) {
    case 0:
        m_lPECUBtnList[index]->setStyleSheet("border-image: url(:/Images/Unknow.png);");
        break;
    case 3:
        m_lPECUBtnList[index]->setStyleSheet("border-image: url(:/Images/PECU_Call.png);");
        break;
    case 2:
        m_lPECUBtnList[index]->setStyleSheet("border-image: url(:/Images/PECU_talkingToCrew.png);");
        break;
    case 1:
        m_lPECUBtnList[index]->setStyleSheet("border-image: url(:/Images/PECUFlt.png);");
        break;
    case 4:
        m_lPECUBtnList[index]->hide();
        break;
    default:
        m_lPECUBtnList[index]->setStyleSheet("border-image: url(:/Images/Unknow.png);");
        break;
    }
}
